
//
//  SearchController.m
//  HandheldHospital
//
//  Created by 张鹏的电脑 on 16/2/27.
//  Copyright © 2016年 zhangchao. All rights reserved.
//

#import "SearchController.h"
#import "SearchCell.h"
#import "SearchModel.h"
#import "ChatController.h"


@interface SearchController ()
@property(nonatomic,strong)NSMutableArray *searchArray;

@end

@implementation SearchController

-(NSMutableArray *)searchArray{
    
    if (!_searchArray) {
        
        _searchArray = [NSMutableArray array];
        NSMutableArray *arrayM = [NSMutableArray arrayWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"yisheng.plist" ofType:nil]];
        for (NSDictionary *dict in arrayM) {
            SearchModel *model = [[SearchModel alloc]initWithDic:dict];
            [_searchArray addObject:model];
            
        }
}
    return _searchArray;
    
}

- (void)viewDidLoad {
    [super viewDidLoad];
    //隐藏tabBar
    self.tabBarController.tabBar.hidden = YES;
    //注册 cell
    [self.tableView registerNib:[UINib nibWithNibName:@"SearchCell" bundle:nil] forCellReuseIdentifier:@"cell"];
    [self.searchArray arrayByAddingObjectsFromArray:[SearchModel search]];
}




- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {

    
    return 1;
}


- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
    return 150;
    
    
}


- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {

    
    return self.searchArray.count;
}


- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
    SearchCell *cell = [tableView dequeueReusableCellWithIdentifier:@"cell" forIndexPath:indexPath];
    

    SearchModel *sm = self.searchArray[indexPath.row];
    
    cell.nameLabel.text = sm.name;
    cell.zhichengLable.text = sm.zhicheng;
    cell.yiyuanLabel.text = sm.yiyuan;
    cell.keleiLabel.text = sm.kelei;
    
    
    
    return cell;
}

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
    ChatController * cc = [[ChatController alloc] init];
    
    [self.navigationController pushViewController:cc animated:YES];
    
    
}


@end
